package com.ruoyi.configManage.controller;

import java.util.List;
import jakarta.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.configManage.domain.WxPayConfig;
import com.ruoyi.configManage.service.IWxPayConfigService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 微信支付配置Controller
 * 
 * @author ruoyi
 * @date 2025-08-12
 */
@RestController
@RequestMapping("/wxPayConfig/wxPayConfig")
public class WxPayConfigController extends BaseController
{
    @Autowired
    private IWxPayConfigService wxPayConfigService;

    /**
     * 查询微信支付配置列表
     */
    @PreAuthorize("@ss.hasPermi('wxPayConfig:wxPayConfig:list')")
    @GetMapping("/list")
    public TableDataInfo list(WxPayConfig wxPayConfig)
    {
        startPage();
        List<WxPayConfig> list = wxPayConfigService.selectWxPayConfigList(wxPayConfig);
        return getDataTable(list);
    }

    /**
     * 导出微信支付配置列表
     */
    @PreAuthorize("@ss.hasPermi('wxPayConfig:wxPayConfig:export')")
    @Log(title = "微信支付配置", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, WxPayConfig wxPayConfig)
    {
        List<WxPayConfig> list = wxPayConfigService.selectWxPayConfigList(wxPayConfig);
        ExcelUtil<WxPayConfig> util = new ExcelUtil<WxPayConfig>(WxPayConfig.class);
        util.exportExcel(response, list, "微信支付配置数据");
    }

    /**
     * 获取微信支付配置详细信息
     */
    @PreAuthorize("@ss.hasPermi('wxPayConfig:wxPayConfig:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Integer id)
    {
        return success(wxPayConfigService.selectWxPayConfigById(id));
    }

    /**
     * 新增微信支付配置
     */
    @PreAuthorize("@ss.hasPermi('wxPayConfig:wxPayConfig:add')")
    @Log(title = "微信支付配置", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody WxPayConfig wxPayConfig)
    {
        return toAjax(wxPayConfigService.insertWxPayConfig(wxPayConfig));
    }

    /**
     * 修改微信支付配置
     */
    @PreAuthorize("@ss.hasPermi('wxPayConfig:wxPayConfig:edit')")
    @Log(title = "微信支付配置", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody WxPayConfig wxPayConfig)
    {
        return toAjax(wxPayConfigService.updateWxPayConfig(wxPayConfig));
    }

    /**
     * 删除微信支付配置
     */
    @PreAuthorize("@ss.hasPermi('wxPayConfig:wxPayConfig:remove')")
    @Log(title = "微信支付配置", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Integer[] ids)
    {
        return toAjax(wxPayConfigService.deleteWxPayConfigByIds(ids));
    }
}
